<!--
 * @Author: dfh
 * @Date: 2024-03-20 10:55:14
 * @LastEditors: dfh
 * @Modified By: dfh
 * @describe: 
-->
<template>
    <view class="nav-wrap">
        <view class="nav-item" v-for="(item,index) in navList" :key="item" @click="onNavItemClick(index)">
            <text class="txt" :class="{'active':index==currentIndex}">{{ item }}</text>
            <text class="line" :class="{'line-active':index==currentIndex}"></text>
        </view>
    </view>
</template>

<script setup>
import {ref} from 'vue';

const emits = defineEmits(['onNavItemClick'])
const props = defineProps({
    navList:{
        type:Array,
        default:()=>[]
    },
    currentIndex:{
        type:Number,
        default:0
    }
})

const onNavItemClick=(index)=>{
    if(index===props.currentIndex) return;
    emits('onNavItemClick',index);
}
</script>

<style lang="scss" scoped>
.nav-wrap {
    width: 100vw;
    height: 80rpx;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    padding-left: 30rpx;

    .nav-item {
        /* width: 100rpx; */
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-right: 30rpx;

        .txt {
            line-height: 60rpx;
            font-size: 28rpx;
            color: rgb(58, 54, 54);
        }

        .line {
            width: 40rpx;
            height: 4rpx;
            border-radius: 2rpx;
            background-color: transparent;
        }

        .active {
            font-weight: 700;
            color: black;
            font-size: 30rpx;
        }

        .line-active {
            background-color: rgba(1, 122, 254, 1);
        }
    }
}
</style>